package com.java.day05;

import com.java.day04.arr.ArrUtils;

import java.util.Random;

public class Cat {
    /**
     * 构造方法
     */

    /**
     * this关键字：
     * 含义：表示当前类的对象,在对象被创建的时候自动产生
     * 作用： 可以调用本类的属性、方法、构造方法
     * ● 调用本类的属性
     * ● 调用本类的方法：
     */
    //无参
    public Cat(){
        this.sex = "公";
        this.happy = 100;
        this.weight = 20;
    }

    //单参
    public Cat(String name){
        this(3);
        this.name = name;
        sex = "公";
        happy = 100;
        weight = 20;
    }

    public Cat(int age){
        this.age = age;
    }

    //全参
    public Cat(String color,String name,int age,String
            sex,int happy,int weight,String breed){
        this.name = name;
        this.color = color;
        this.age = age;
        this.sex = sex;
        this.breed = breed;
        this.happy = happy;
        this.weight = weight;
    }




    /**
     * 属性
     */
    //品种
    String breed;

    //颜色
    String color;

    //年龄
    int age;

    //名字
    String name;

    //性别
    String sex;

    //心情值
    int happy;

    //体重
    int weight;



    /**
     * 实例方法(行为)
     */
    //吃
    public void eat(){
        Random random = new Random();
        int food = 1+random.nextInt(3);

        if(food==1){
            System.out.println(name+"吃了"+food+"猫罐头,"+"没吃饱,有点不高兴!");
            weight = weight+1;
            happy = happy-1;
            System.out.println("体重上涨为"+weight+","+"心情值下降为"+happy);
            System.out.println();

        }else if (food==2){
            System.out.println(name+"吃了"+food+"猫罐头,"+"吃饱啦,非常满足!");
            weight = weight+2;
            happy = happy+2;
            System.out.println("体重上涨为"+weight+","+"心情值上涨为"+happy);
            System.out.println();

        }else{
            System.out.println(name+"吃了"+food+"猫罐头,"+"吃撑啦,肚子好痛!");
            weight = weight+3;
            happy = happy-2;
            System.out.println("体重上涨为"+weight+","+"心情值下降为"+happy);
            System.out.println();

        }

    }

    //睡
    public void sleep(){
        System.out.println(name+"困了,伸了一个懒腰,然后安稳的进入了梦乡");
        happy = happy+2;
        System.out.println("心情值上涨为"+happy);
        System.out.println();
    }

    //抓鱼
    public void catchFish(){
        Random random = new Random();
        int caught = random.nextInt(1);
        if (caught==1){
            System.out.println(name+"抓到了一条大鱼,并美美的饱餐了一顿");
            weight = weight+2;
            happy = happy+5;
            System.out.println("体重上涨为"+weight+","+"心情值上涨为"+happy);
            System.out.println();
        }else{
            System.out.println(name+"没有抓到,可恶!!!让它给跑了");
            happy = happy-2;
            System.out.println("心情值下降为"+happy);
            System.out.println();
        }

    }

    //冒泡排序
    public void bubbleSort(int[] array){
        System.out.println(name+"看了眼它主人的代码,实在看不下去了,抄起键盘,反手就是一个冒泡排序");
        ArrUtils.bubbleSort(array);
        System.out.println();
    }

    //后空翻
    public void back(){
        System.out.println("来"+name+"给他整个活儿,草,走,忽略!");
        System.out.println();
    }

    //输出全部属性
    @Override
    public String toString() {
        return "Cat{" +
                "breed='" + breed + '\'' +
                ", color='" + color + '\'' +
                ", age=" + age +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", happy=" + happy +
                ", weight=" + weight +
                '}';
    }

    /**
     * 静态方法
     */

    //开光
    public static void kg() {
        System.out.println("                       _oo0oo_");
        System.out.println("                      o8888888o");
        System.out.println("                     88\" . \"88");
        System.out.println("                      (| -_- |)");
        System.out.println("                     0\\  =  /0");
        System.out.println("                    ___/`---'\\___");
        System.out.println("                  .' \\|     |// '.");
        System.out.println("                / _||||| -:- |||||- \\");
        System.out.println("               |   | \\\\\\  -  /// |   |");
        System.out.println("               | \\_|  ''\\---/''  |_/ |");
        System.out.println("               \\  .-\\__  '-'  ___/-. /");
        System.out.println("             ___'. .'  /--.--\\  `. .'___");
        System.out.println("          .\"\" '<  `.___\\_<|>_/___.' >' \"\".");
        System.out.println("         | | :  `- \\`.;`\\ _ /`;.`/ - ` : | |");
        System.out.println("         \\  \\ `_.   \\_ __\\ /__ _/   .-` /  /");
        System.out.println("     =====`-.____`.___ \\_____/___.-`___.-'=====");
        System.out.println("                       `=---='");
        System.out.println("                                                ");
        System.out.println("                                                ");
        System.out.println("     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~         ");
        System.out.println("                    佛祖保佑         永无BUG         ");
    }


    //随机猫
    public static Cat random(){
        Cat cat = new Cat();
        String[] names = {"小叮当","tom","加菲","HelloKitty","坤坤"};
        Random random = new Random();
        int index = random.nextInt(names.length); // [0,4]
        cat.name = names[index];
        cat.sex = random.nextInt(2)>0?"男":"女";
        cat.weight = random.nextInt(100);
        cat.happy = random.nextInt(100);
        cat.age = 1+random.nextInt(5);
        return cat;
    }


}


